import { Random } from 'mockjs';
import { resultSuccess, doCustomTimes } from '../_util';

const tableList = (pageSize) => {
    const result: any[] = [];
    doCustomTimes(pageSize, () => {
        result.push({
            index: 1,
            id: '@integer(10,999999)',
            beginTime: '@datetime',
            endTime: '@datetime',
            name: '公安部',
            avatar: Random.image('400x400', Random.color(), Random.color(), Random.first()),
            date: `@date('yyyy-MM-dd')`,
            time: `@time('HH:mm')`,
            'no|100000-10000000': 100000,
            'status|1': [true, false],
            children: [
                {
                    id: '@integer(10,999999)',
                    name: '温岭大队',
                    children: [
                        {
                            id: '@integer(10,999999)',
                            name: '城区一中队',
                            children: [
                                {
                                    id: '@integer(10,999999)',
                                    name: '路桥中队',
                                }
                            ]
                        },
                    ]
                },
                {
                    id: '@integer(10,999999)',
                    name: '永嘉大队',
                    children: [
                        {
                            id: '@integer(10,999999)',
                            name: '上塘一中队',
                            children: [
                                {
                                    id: '@integer(10,999999)',
                                    name: '碧莲中队'
                                }
                            ]
                        }
                    ]
                }
            ]
        });
    });
    return result;
};

export default [
    //表格数据列表
    {
        url: '/api/table/zhankaiList',
        timeout: 1000,
        method: 'get',
        response: ({ query }) => {
            const { page = 1, pageSize = 10 } = query;
            const list = tableList(Number(pageSize));
            return resultSuccess({
                page: Number(page),
                pageSize: Number(pageSize),
                pageCount: 60,
                list,
            });
        },
    },
];
